package LeetCode.Simple;
/*
斐波拉契数列
 */
public class Question004 {
    public int fib(int n){
        int temp = 0;
        int a = 1;
        int b = 2;
//        if(n == 1 || n == 2){
//            return n;
//        }else{
//            return fib(n-1) + fib(n-2);
//        }

        for (int i = 3; i <= n; i++) {
            temp = a;
            a = b;
            b = b + temp;
        }
        return b;
    }
}

